<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/4/19
  Time: 16:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>供应商管理系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
</head>

<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span id="span1" class="tpl-header-list-user-nick"></span><span class="tpl-header-list-user-ico"> <img
                        src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="login.jsp"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
        </ul>
    </div>
</header>
<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-wpforms"></i>
                        <span>企业管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="info-certification.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>企业信息认证</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-table"></i>
                        <span>供应商管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display:block">
                        <li>
                            <a href="white-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商白名单</span>
                            </a>
                            <a href="black-list.jsp" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商黑名单</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            供应商黑名单列表
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">供应商管理</a></li>
            <li class="am-active">供应商黑名单</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-6 am-u-md-2">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">企业名称</span>
                                </span>
                            <input name="enamess" type="text" class="am-form-field" placeholder="&nbsp;&nbsp;请输入企业名称"
                                   style="border: 1px solid #c2cad8;border-radius: 3px;">
                        </div>
                    </div>
                    <%--<div class="am-u-sm-6 am-u-md-3">
                        <div class="am-form-group">
                            <span style="font-size: 14px;">企业评级</span>
                            <select data-am-selected="{btnSize: 'sm'}">
                                <option value="">请选择企业评级</option>
                                <option value="a">1级</option>
                                <option value="b">2级</option>
                                <option value="c">3级</option>
                            </select>
                        </div>
                    </div>--%>
                    <%--<input id="f1" type="button" value="查询企业信息">--%>
                    <div style="float:right">
                        <div class="am-form-group">
                            <button type="button" class="am-btn am-btn-primary am-btn-sm"
                                    id="doc-prompt-toggle">添加供应商
                            </button>
                        </div>
                    </div>
                    <div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
                        <div class="am-modal-dialog">
                            <form action="" class="am-form am-form-horizontal">
                                <legend style="font-size: 18px;padding: 12px 0;">添加供应商</legend>
                                <div class="am-form-group">
                                    <label for="doc-select-1" class="am-u-sm-4 am-form-label"
                                           style="font-size: 15px;">企业名称</label>
                                    <div class="am-u-sm-6">
                                        <select id="doc-select-1" required>
                                            <option value="">请选择企业</option>
                                            <%--<option value="a">腾讯科技</option>
                                            <option value="b">京东集团</option>
                                            <option value="c">搜狐</option>
                                            <option value="d">阿里巴巴</option>
                                            <option value="e">小米</option>--%>
                                        </select>
                                    </div>
                                    <span class="am-form-caret"></span>
                                </div>
                                <div class="am-form-group">
                                    <label for="doc-select-2" class="am-u-sm-4 am-form-label"
                                           style="font-size: 15px;">统一社会信用代码</label>
                                    <div class="am-u-sm-6" style=" text-align: left;margin-top: 6px;">
                                        <span id="social_uniform_code"></span>
                                    </div>
                                    <span class="am-form-caret"></span>
                                </div>
                                <div class="am-form-group" style="margin-bottom: 20px;">
                                    <label for="doc-select-2" class="am-u-sm-4 am-form-label"
                                           style="font-size: 15px;">添加理由</label>
                                    <div class="am-u-sm-6" >
                                        <textarea class="" rows="4" id="user-intro" placeholder="请输入添加理由"></textarea>
                                    </div>
                                    <span class="am-form-caret"></span>
                                </div>
                            </form>
                            <div class="am-modal-footer" style="border-top: 1px solid #dedede;">
                                <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                                <span class="am-modal-btn" data-am-modal-confirm>提交</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <th class="table-id">序号</th>
                                    <th class="table-title">企业名称</th>
                  <%--                  <th class="table-type">企业联系人</th>--%>
                                    <th class="table-author am-hide-sm-only">联系方式</th>
                                    <th class="table-date am-hide-sm-only">联系邮箱</th>
                                    <th class="table-date am-hide-sm-only">添加理由</th>
                                    <th class="table-date am-hide-sm-only">更新日期</th>
                                    <th class="table-set">操作</th>
                                </tr>
                                </thead>
                                <tbody id="doc-modal-list">
                                <tr data-id="2">
                                    <td>1</td>
                                    <td class="am-hide-sm-only"><a href="#">腾讯科技</a></td>
                                    <%--<td class="am-hide-sm-only">马化腾</td>--%>
                                    <td class="am-hide-sm-only">18556658588</td>
                                    <td class="am-hide-sm-only">18556658588@163.com</td>
                                    <td class="am-hide-sm-only">
                                        <div class="">
                                            不予考虑
                                        </div>
                                    </td>
                                    <td class="am-hide-sm-only">2021-12-31</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                        <span class="am-text-secondary am-icon"
                                                              style="cursor:pointer"><span></span>
                                                            解除黑名单</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
                                    <div class="am-modal-dialog" style="font-size: 16px;">
                                        <div class="am-modal-hd">提示</div>
                                        <div class="am-modal-bd">
                                            将供应商解除黑名单后该企业可继续在平台进行融资，是否继续？
                                        </div>
                                        <div class="am-modal-footer">
                                            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                                            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
                                        </div>
                                    </div>
                                </div>
                                <tr>
                                    <td>1</td>
                                    <td><a href="#">京东集团</a></td>
                                    <%--<td>刘强东</td>--%>
                                    <td class="am-hide-sm-only">18556658588</td>
                                    <td class="am-hide-sm-only">18556658588@163.com</td>
                                    <td class="am-hide-sm-only">
                                        <div class="">
                                            /
                                        </div>
                                    </td>
                                    <td class="am-hide-sm-only">2021-12-31</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                        <span class="am-text-secondary am-icon"
                                                              style="cursor:pointer"><span></span>
                                                            解除黑名单</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>1</td>
                                    <td><a href="#">搜狐</a></td>
                                    <%--<td>张朝阳</td>--%>
                                    <td class="am-hide-sm-only">18556658588</td>
                                    <td class="am-hide-sm-only">18556658588@163.com</td>
                                    <td class="am-hide-sm-only">
                                        <div class="">
                                            考察不通过
                                        </div>
                                    </td>
                                    <td class="am-hide-sm-only">2021-12-31</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                        <span class="am-text-secondary am-icon"
                                                              style="cursor:pointer"><span></span>
                                                            解除黑名单</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>1</td>
                                    <td><a href="#">阿里巴巴</a></td>
                                    <%--<td>马云</td>--%>
                                    <td class="am-hide-sm-only">18556658588</td>
                                    <td class="am-hide-sm-only">18556658588@163.com</td>
                                    <td class="am-hide-sm-only">
                                        <div class="">
                                            不符合相关条件
                                        </div>
                                    </td>
                                    <td class="am-hide-sm-only">2021-12-31</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                        <span class="am-text-secondary am-icon"
                                                              style="cursor:pointer"><span></span>
                                                            解除黑名单</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>1</td>
                                    <td><a href="#">小米</a></td>
                                    <%--<td>雷军</td>--%>
                                    <td class="am-hide-sm-only">18556658588</td>
                                    <td class="am-hide-sm-only">18556658588@163.com</td>
                                    <td class="am-hide-sm-only">
                                        <div class="">
                                            /
                                        </div>
                                    </td>
                                    <td class="am-hide-sm-only">2021-12-31</td>
                                    <td>
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                        <span class="am-text-secondary am-icon"
                                                              style="cursor:pointer"><span></span>
                                                            解除黑名单</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <%--<div class="am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <li class="am-disabled"><a href="#">«</a></li>
                                        <li class="am-active"><a href="#">1</a></li>
                                        <li><a href="#">2</a></li>
                                        <li><a href="#">3</a></li>
                                        <li><a href="#">4</a></li>
                                        <li><a href="#">5</a></li>
                                        <li><a href="#">»</a></li>
                                    </ul>
                                </div>
                            </div>--%>
                            <div id="divbut"></div>
                            <hr>
                        </form>
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script>






    // 添加供应商
    $(function () {
        $('#doc-prompt-toggle').on('click', function () {
            $('#my-prompt').modal({
                relatedTarget: this,
                onConfirm: function (options) {

                    //获得写的理由
                    var str = $("#user-intro").val();

                    //这是供货商的企业的 名称
                    var enamess = sessionStorage.getItem("nowEname");

                    //登录的企业名称
                    var localename = sessionStorage.getItem("localEname");


                    //点击确认调用函数
                    alert("点击了确认");
                    $.get("black/addSup",
                        {
                            "str":str,
                            "enamess":enamess,
                            "localename":localename
                        },function (mess) {
                            //应该传个添加成功的boo
                            if(JSON.parse(mess)){
                                alert("添加成功");
                            }else{
                                alert("添加失败");
                            }
                        });

                },
                onCancel: function (e) {
                    //点击取消调用函数
                    alert("点击了取消")
                }
            });
        });
    });

    $(document).ready(function () {
        $("#span1").html(sessionStorage.getItem("account"));

        var account = sessionStorage.getItem("account");
        var password = sessionStorage.getItem("password");
        $.get("black/ajaxFindUsers","account="+account+"&password="+password,function (mess) {
            eval("var info="+mess);

            //处理下拉列表，添加可以选择的黑名单供应商
            var eid = info.enterprise_id;
            $.get("black/findSupId","eid="+eid,function (mess) {
                eval("var sname=" + mess);
                $("#doc-select-1").empty();
                for (var i = 0; i < sname.length; i++) {
                    $("<option value='" + sname[i].enamess + "'>" + sname[i].enamess + "</option>").appendTo("#doc-select-1");
                }

                //展示一进来的对应企业的信用码
                var codename = $("#doc-select-1>option").val();
                sessionStorage.setItem("nowEname",codename);
                $.get("black/findCodeByName", "enamess=" + codename, function (mess) {
                    eval("var nowCode=" + mess);
                    $("#social_uniform_code").html(nowCode);
                });

                //展示对应企业的信用码
                $("#doc-select-1").change(function () {
                    var nowEname = $(this).val();
                    sessionStorage.setItem("nowEname",nowEname);
                    $.get("black/findCodeByName", "enamess=" + nowEname, function (mess) {
                        eval("var nowCode=" + mess);
                        $("#social_uniform_code").empty();
                        $("#social_uniform_code").html(nowCode);
                    });
                });
            });



            //判断这个用户是否是第一次登陆，即判断他的属性：企业名称是否为空
            if(info.enterprise_name != null){
                sessionStorage.setItem("localEname",info.enterprise_name);
                var enamess=$("[name=enamess]").val()==null?"":$("[name=enamess]").val();
                $.get("black/ajaxGetBlackAll",
                    {
                        "account":account,
                        "password":password,
                        "enamess":enamess
                    }, function (mess) {
                        eval("var ph="+mess);
                        Show(ph);
                    });
            }else{
                $("tbody").empty();
            }
        });







        //为分页按钮动态绑定单机事件
        $(document).on("click","[name=page]",function () {
            var id=$(this).attr("id");
            var enamess=$("[name=enamess]").val()==null?"":$("[name=enamess]").val();
            $.get("black/ajaxGetBlackAll",{
                "account":account,
                "password":password,
                "enamess":enamess,
                "indexPage":id
            },function (mess) {
                eval("var ph="+mess);
                Show(ph);
            });
        });






        /*//查询按钮被点击后，查询数据
        $("#f1").click(function () {
            var enamess=$("[name=enamess]").val()==null?"":$("[name=enamess]").val();

            $.get("black/ajaxquery",
                {
                    "account":account,
                    "password":password,
                    "enamess":enamess
                },function (mess) {
                    eval("var ph="+mess);
                    Show(ph);
                });
        });*/

        //企业名称失焦后，查询数据
        $("[name=enamess]").blur(function () {
            var enamess=$("[name=enamess]").val()==null?"":$("[name=enamess]").val();

            $.get("black/ajaxquery",
                {
                    "account":account,
                    "password":password,
                    "enamess":enamess
                },function (mess) {
                    eval("var ph="+mess);
                    Show(ph);
                });
        });












        // 解除黑名单
        $(document).on("click","[class^=am-text-secondary]",function () {
            var id=$(this).attr("id");
            alert("您将要解除"+id+"吗？");
            //解除的企业名称
            var enamess = id;

            //当前登录的企业的名称
            var localenames = sessionStorage.getItem("localEname");


            $('#my-confirm').modal({
                relatedTarget: this,
                onConfirm: function (options) {
                    //点击确认调用函数
                    alert("点击了确认");
                    $.get("black/blackDel",
                        {
                            "enamess":enamess,
                            "localename":localenames
                        },function (mess) {
                            if(JSON.parse(mess)){
                                alert("解除黑名单成功")
                            }else{
                                alert("解除失败")
                            }
                        })
                },
                onCancel: function (e) {
                    //点击取消调用函数
                    alert("点击了取消")
                }
            });
        });

    });



    //提取出来的数据显示函数：
    function Show(ph) {
        $("tbody").empty();
        for(var i=0;i<ph.list.length;i++){
            $("<tr>" +
                "<td>"+ph.list[i].bid+"</td>" +
                "<td>"+ph.list[i].enamess+"</td>" +
                "<td>"+ph.list[i].ephone+"</td>" +
                "<td>"+ph.list[i].email+"</td>" +
                "<td>"+ph.list[i].reason+"</td>" +
                "<td>"+ph.list[i].update_date+"</td>" +
                "<td><div class=\"am-btn-toolbar\">\n" +
                "                                            <div class=\"am-btn-group am-btn-group-xs\">\n" +
                "                                                        <span id='"+ph.list[i].enamess+"' class=\"am-text-secondary am-icon\"\n" +
                "                                                              style=\"cursor:pointer\"><span></span>\n" +
                "                                                            解除黑名单</span>\n" +
                "                                            </div>\n" +
                "                                        </div></td>" +
                "</tr>").appendTo("tbody");
        }
        $("#divbut").empty();
        if(ph.indexPage!=1){
            $("<input type='button' name='page' id='1'  value='首页'/>").appendTo("#divbut");
            $("<input type='button' name='page' id='"+(ph.indexPage-1)+"' value='上一页'/>").appendTo("#divbut");
        }
        if(ph.indexPage!=ph.totalPage){
            $("<input type='button' name='page' id='"+(ph.indexPage+1)+"' value='下一页'/>").appendTo("#divbut");
            $("<input type='button' name='page' id='"+ph.totalPage+"'  value='尾页'/>").appendTo("#divbut");
        }
        $("<span>"+ph.indexPage+"/"+ph.totalPage+" </span>").appendTo("#divbut");
    }







</script>
</body>
</html>
